package nio.Bchannel;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

/**
 * @author 帅小伙
 * @date 2022/1/14
 * @description
 * 拷贝一张图片
 */
public class FileChannel04 {

    public static void main(String[] args) throws Exception {
        FileInputStream inputStream = new FileInputStream("file1.txt");
        FileOutputStream fileOutputStream = new FileOutputStream("file2.txt");

        FileChannel sourceCh = inputStream.getChannel();
        FileChannel distCH = fileOutputStream.getChannel();
        //快速拷贝
        distCH.transferFrom(sourceCh,0,sourceCh.size());

        fileOutputStream.close();
        inputStream.close();


    }
}
